<template>
  <div class="home">
    <better-scroll>
      <banner url="https://cdn.pixabay.com/photo/2015/04/19/08/32/marguerite-729510_960_720.jpg"></banner>
      <h2 class="list-title">推荐动态</h2>
      <ul class="recommond-list">
        <li class="recommond-item" v-for="(item, idx) in 20" :key="idx" @click.prevent="jumpToArticleDetial(item)">
          <div class="preview">
            <img src="https://cdn.pixabay.com/photo/2014/08/25/14/12/pansy-427139_960_720.png" alt="">
          </div>
          <div class="infomation">
            <section class="summary">第一次自己种肉肉，迫不及待的种上了，希望肉肉第一次自己种肉肉，迫不及待的种上了，希望肉肉一切都好。不得不说真的太喜欢了，长长应该会更漂亮。</section>
            <div class="other-info">
              <div class="author" @click.stop="jumpToAuthor(item)">
                <div class="avatar">
                  <img src="https://cdn.pixabay.com/photo/2013/07/13/10/07/man-156584_960_720.png" alt="">
                </div>
                <h3>浅月于静</h3>
              </div>
              <p class="publish-time">2018年12月12日</p>
            </div>
          </div>
        </li>
      </ul>
    </better-scroll>
  </div>
</template>

<script>
import BetterScroll from '@/components/BetterScroll.vue'
import Banner from '@/components/Banner.vue'

export default {
  methods: {
    jumpToAuthor (aId) {
      console.log(aId)
      this.$router.push(`/author/${aId}`)
    },

    jumpToArticleDetial (articleId) {
      console.log(articleId)
      this.$router.push(`/article-detail/${articleId}`)
    }
  },

  components: {
    BetterScroll,
    Banner
  }
}
</script>

<style scoped>
.home {
  height: 100%;
  padding-bottom: 96px;
  box-sizing: border-box;
}
.list-title {
  height: 70px;
  line-height: 70px;
  padding: 0 25px;
  font-size: 34px;
  color: #666;
  background-color: #E1E1E1;
}
.recommond-item {
  height: 174px;
  padding: 20px 0;
  margin: 0 14px;
  border-bottom: 1px solid #C9C9C9;
  display: flex;
  justify-content: space-between;
}
.recommond-item:last-child {
  border-bottom: none;
}
.preview {
  width: 202px;
  height: 100%;
  flex-shrink: 0;
  overflow: hidden;
  background-color: #f2f2f2;
}
.preview > img {
  display: block;
  width: 100%;
  object-fit: cover;
}
.infomation {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  margin-left: 26px;
}
.summary {
  font-size: 26px;
  color: #666;
  line-height: 38px;
  overflow:hidden;
  text-overflow:ellipsis;
  display:-webkit-box;
  -webkit-line-clamp:3;
  -webkit-box-orient:vertical;
}
.other-info {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-column-gap: 20px;
  grid-template-rows: 32px;
}
.author {
  display: flex;
  align-items: center;
}
.avatar {
  width: 31px;
  height: 31px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid #999;
  flex-shrink: 0;
  margin-right: 14px;
}
.avatar > img {
  display: block;
  width: 100%;
  object-fit: cover;
}
.author > h3, .publish-time {
  font-size: 22px;
  color: #999;
}
.other-info > p {
  line-height: 32px;
  text-align: right;
}
</style>
